<template>
	<view class="content" :class="{'scrollLock':isStopBodyScroll}">
		<!-- 按钮 -->
		<view class="fixed-button-area">
			<view class="custom-style">
				<u-button type="primary" :plain="true" text="发送" size="small" @click="handleAdd"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="success" :plain="true" text="修改" size="small" @click="handleUpdate"
					:disabled="checkboxValue1.length<1"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="warning" :plain="true" text="删除" size="small" @click="handleDelete"
					:disabled="checkboxValue1.length<1"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="primary" :plain="true" text="解锁" size="small" @click="handleUnlock"
					:disabled="checkboxValue1.length<1"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="primary" :plain="true" text="重置密码" size="small" @click="handleResetPwd"
					:disabled="checkboxValue1.length<1"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="primary" :plain="true"  text="发送记录" size="small" @click="handlePush"></u-button>
			</view>
			<view class="custom-style">
				<u-button type="primary" :plain="true" text="刷新" size="small" @click="getList"></u-button>
			</view>
			<!-- <view style="margin: 0 20rpx;">
				<u-icon name="reload" @click="getList" size="28"></u-icon>
			</view> -->
		</view>
		<!-- <view class="upload-img">
			<uni-file-picker limit="6" @select='selectUpload' :auto-upload='false' file-extname='xlsx, xls'
				file-mediatype="all" @success='uploadSuccess' @fail='uploadFail' :list-styles='listStyles'
				v-model='fileList'>
				<button>点击上传</button>
			</uni-file-picker>

		</view> -->
		<!-- 列表 -->
		<view class="list-container">
			<u-list @scrolltolower="scrolltolower" @scroll="onscroll" :scrollTop="scrollTop" class="list-inner">
				<checkbox-group @change="checkboxChange" style="display: flex; flex-direction: column; width: 100%;">
					<u-list-item :key="index" v-for="(item,index) in TaskManagementList">
						<!-- <u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange(item)"> -->

						<uni-card :is-shadow="true">
							<u-row customStyle="margin-bottom: 10px">
								<checkbox :key="item.taskId" label=" " :checked="item.checked" :value="item.taskId">
								</checkbox>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">位置</view>
								</u-col>
								<u-col span="8">
									<!-- <view class="demo-layout ">{{item.taskLocation}}</view> -->
									<u-read-more :toggle="true" showHeight="100" textIndent="0em" closeText="展开"
										:shadowStyle="shadowStyle">
										<rich-text :nodes="item.taskLocation"></rich-text>
									</u-read-more>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">风险部位</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.taskBw}}</view>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">危险源</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.taskYuan}}</view>
								</u-col>
							</u-row>

							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">控制措施</view>
								</u-col>
								<u-col span="8">
									<!-- <view class="demo-layout ">{{item.taskCs}}</view> -->
									<u-read-more :toggle="true" showHeight="100" textIndent="0em" closeText="展开"
										:shadowStyle="shadowStyle">
										<rich-text :nodes="item.taskCs"></rich-text>
									</u-read-more>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">排查人</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.taskPcName}}</view>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">排查账号</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.taskPcNumber}}</view>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px" v-if="item.taskFile">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">示例图片</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout " @click="imgpre(item.taskFile)">
										<image style="width: 80px;height: 80px;"
											:src="'http://192.168.1.143:8089/common/file/'+item.taskFile+'/preview'"
											mode="aspectFill" class="photo-img"></image>
									</view>
								</u-col>
							</u-row>
							<u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">发起人</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.taskUserName}}</view>
								</u-col>
							</u-row>
							<!-- <u-row customStyle="margin-bottom: 10px">
								<u-col span="4">
									<view class="demo-layout bg-purple-light">创建时间</view>
								</u-col>
								<u-col span="8">
									<view class="demo-layout ">{{item.createTime}}</view>
								</u-col>
							</u-row> -->
						</uni-card>
						<!-- </u-cell> -->

					</u-list-item>
				</checkbox-group>
			</u-list>
		</view>
		<!-- <l-pagination v-model="queryParams.pageNum" :total="total" :page-size="queryParams.pageSize" :pager-count="3"
			v-if="total>0" @change="changes" /> -->

		<!-- 新增、修改模态框 -->
		<u-modal :show="show" :title="title" @confirm="confirm" @cancel="cancel" showCancelButton="true">
			<u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm" :labelWidth='90'>
				<u-form-item label="风险部位" prop="taskBw" borderBottom ref="item1">
					<u--input v-model="model1.taskBw" showWordLimit maxlength="50"></u--input>
				</u-form-item>
				<u-form-item label="危险源" prop="taskYuan" borderBottom ref="item1">
					<u--input v-model="model1.taskYuan" showWordLimit maxlength="50"></u--input>
				</u-form-item>
				<u-form-item label="位置" prop="taskLocation" borderBottom ref="item1">
					<u--input v-model="model1.taskLocation" showWordLimit maxlength="30"></u--input>
				</u-form-item>
				<u-form-item label="控制措施" prop="taskCs" borderBottom ref="item1">
					<u--textarea v-model="model1.taskCs" showWordLimit maxlength="500"></u--textarea>
				</u-form-item>
				<u-form-item label="排查人" prop="taskPcName" borderBottom ref="item1">
					<u--input v-model="model1.taskPcName" showWordLimit maxlength="500"></u--input>
				</u-form-item>
				<u-form-item label="示例图片" prop="taskFile" borderBottom ref="item1">
					<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" :maxCount="1"
						:previewFullImage="true"></u-upload>
				</u-form-item>

			</u--form>
		</u-modal>
		<!-- 删除模态框 -->
		<u-modal :show="showDetle" title="删除提示" :content='content' @confirm="confirmDetle" @cancel="cancelDetle"
			showCancelButton="true"></u-modal>
		<!-- 创建项目名称对话框 -->
		<u-modal :show="showProjectNameDialog" title="发送创建项目" @confirm="confirmProjectName" :closeOnClickOverlay="true"
			showCancelButton="true" confirmText="下一步" @cancel="showProjectNameCancel">
			<view style="position: absolute;right: 5%;top: 3%;font-size: 30px;" @click="close">×</view>
			<view style="margin-bottom: 10px;display: flex;">
				<text style="margin-top: 8px;margin-right: 5px;font-size: 16px;">项目名称</text>
				<!-- 	<u--input v-model="projectName"
					placeholder="请输入项目名称"></u--input> -->
				<uni-easyinput v-model="projectName" placeholder="请输入项目名称" />
			</view>
		</u-modal>

		<!-- 发送日期选择对话框 -->
		<u-modal :show="showSendDateDialog" title="选择发送日期" @confirm="confirmSendDate" :closeOnClickOverlay="true"
			showCancelButton="true" cancelText="上一步" confirmText="下一步" @cancel="showSendDateCancel">
			<view style="position: absolute;right: 5%;top: 3%;font-size: 30px;" @click="close">×</view>
			<view class="send-type-select">
				<view style="margin-bottom: 15px;">
					<u-radio-group v-model="sendType" placement="row">
						<u-radio :name="'immediate'" label="立即发送" :customStyle="{marginRight: '30px'}"></u-radio>
						<u-radio :name="'scheduled'" label="指定日期发送"></u-radio>
					</u-radio-group>
				</view>
				<view>
					<uni-datetime-picker type="date" :clear-icon="false" v-if="sendType === 'scheduled'"
						v-model="selectedSendDate" :start="start" />
				</view>
				<!-- <u-date-picker v-if="sendType === 'scheduled'" v-model="selectedSendDate" mode="date"
					:start-date="new Date().toISOString().split('T')[0]" title="选择发送日期"></u-date-picker> -->

			</view>
		</u-modal>

		<!-- 截止日期选择对话框 -->
		<u-modal :show="showDeadlineDialog" title="选择截止日期" @confirm="confirmDeadline" :closeOnClickOverlay="true"
			showCancelButton="true" cancelText="上一步" confirmText="下一步" @cancel="showDeadlineCancel">
			<view style="position: absolute;right: 5%;top: 3%;font-size: 30px;" @click="close">×</view>
			<view style="width: 100%;display: flex;">
				<text style="margin-top: 8px;margin-right: 5px;font-size: 16px;">截止日期</text>
				<uni-datetime-picker :start="end" type="date" :clear-icon="false" v-model="selectedDeadline" />
			</view>
		</u-modal>

		<!-- 最终确认对话框 -->
		<u-modal :show="showConfirmDialog" title="发送任务确认" @confirm="finalConfirmSend" :closeOnClickOverlay="true"
			showCancelButton="true" cancelText="上一步" @cancel="showConfirmCancel" confirmText="确认发送">
			<view style="position: absolute;right: 5%;top: 3%;font-size: 30px;" @click="close">×</view>
			<view style="width: 100%;">
				<view class="confirm-message" v-if="total>0">
					本次发送任务{{ checkboxValue1.length? checkboxValue1.length:total}}条</view>
				<view style="width: 300px;margin-bottom: 20px;max-height: 300px;overflow: auto;">
					<uni-table ref="table" border stripe emptyText="暂无更多数据">
						<uni-tr>
							<uni-th width="150" align="center">风险部位</uni-th>
							<uni-th width="150" align="center">危险源</uni-th>
							<uni-th width="150" align="center">位置</uni-th>
							<uni-th width="150" align="center">控制措施</uni-th>
							<uni-th width="150" align="center">排查单位(人)</uni-th>
							<uni-th width="150" align="center">排查账号</uni-th>
							<uni-th width="150" align="center">发起人</uni-th>
							<!-- <uni-th width="160" align="center">创建时间</uni-th> -->
						</uni-tr>
						<uni-tr v-for="(item1, indexs) in dataList" :key="indexs">
							<uni-td align="center">
								<view class="name">{{ item1.taskBw?item1.taskBw:'' }}</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">{{ item1.taskYuan?item1.taskYuan:'' }}</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">{{ item1.taskLocation?item1.taskLocation:'' }}</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">
									{{ item1.taskCs?item1.taskCs:'' }}
								</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">{{ item1.taskPcName?item1.taskPcName:'' }}</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">{{ item1.taskPcNumber?item1.taskPcNumber:'' }}</view>
							</uni-td>
							<uni-td align="center">
								<view class="name">{{ item1.taskUserName?item1.taskUserName:'' }}</view>
							</uni-td>
							<!-- <uni-td align="center">
								<view class="name">{{ item1.createTime?item1.createTime:'' }}</view>
							</uni-td> -->
						</uni-tr>
					</uni-table>
					<!-- 	<l-pagination v-model="queryParams.pageNum" :total="total" :page-size="queryParams.pageSize"
						:pager-count="3" v-if="total>0" @change="change1" /> -->
					<uni-pagination :total="total" title="标题文字" style="height: 50px;" @change="change1"
						v-if="total>0" />
				</view>
				<view class="confirm-message">
					任务发送日期:{{ sendType === 'immediate' ? formatDateText(data) :formatDateText(selectedSendDate) }}
				</view>
				<view class="confirm-message">任务截止日期:{{ formatDateText(selectedDeadline)}}</view>
			</view>
		</u-modal>
		<!-- 解锁 -->
		<u-modal :show="showUnlock" title="系统提示" :content='contentUnlock' @confirm="confirmUnlock"
			@cancel="cancelUnlock" showCancelButton="true"></u-modal>
		<!-- 重置密码 -->
		<u-modal :show="showResetPwd" title="系统提示" :content='contentResetPwd' @confirm="confirmResetPwd"
			@cancel="cancelResetPwd" showCancelButton="true">
			<u--input placeholder="请输入新密码" border="surround" v-model="password"></u--input>
		</u-modal>
		<!-- 发送记录弹出框 -->
		<u-modal :show="showPushDialog" title="发送记录" @confirm="confirmPush">
			<uni-table ref="table" border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th width="150" align="center">项目名称</uni-th>
					<uni-th width="50" align="center">操作</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in pushList" :key="index" @row-click="lookDetail(item.recordId)">
					<uni-td align="center" >
						<view class="name">{{ item.recordTaskName?item.recordTaskName:'' }}</view>
					</uni-td>
					<uni-td align="center">
						<view >
							<u-button style="width: 30%;" type="primary" :plain="true" text="复用" size="small" @click.prevent="repeat(item.recordId)"></u-button>
						</view>
					</uni-td>
				</uni-tr>
			</uni-table>
		</u-modal>
		<!-- 加载 -->
		<u-loading-page :loading="showLoading"></u-loading-page>
		<u-back-top :scroll-top="innerScrollTop" top="100" @click="changes"></u-back-top>
		<u-toast ref="uToast"></u-toast>
		<tabBar selectedIndex=0></tabBar>
	</view>
</template>

<script>
	import {
		listTaskManagement,
		sendTask,
		updateTaskManagement,
		delTaskManagement,
		upload,listRecord,recordDetail
	} from '@/api/system/work.js'
	import {
		resetUserPwd,
		unlockLogininfor
	} from '@/api/system/user.js'
	import {
		getToken
	} from '@/utils/auth'
	export default {
		data() {
			return {
				show: false,
				title: '标题',
				content: '是否删除选中数据',
				model1: {},
				rules: {},
				checkboxValue1: [],
				showDetle: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 999,
					taskBw: null,
					taskYuan: null,
					taskLocation: null,
					taskCs: null,
					taskPcName: null,
					taskPcNumber: null,
					taskUserName: null,
					createTime: null,
				},
				TaskManagementList: [],
				currentPage: 1,
				total: 0,
				showProjectNameDialog: false,
				projectName: '',
				showSendDateDialog: false,
				sendType: 'immediate', // immediate: 立即发送, scheduled: 定时发送
				selectedSendDate: '',
				showDeadlineDialog: false,
				selectedDeadline: '',
				showConfirmDialog: false,
				confirmMessage: '',
				sendCount: 5, // 假设从接口获取的发送次数
				hasSentToday: false, // 今天是否已发送
				shadowStyle: {
					backgroundImage: "none",
					paddingTop: "0",
					marginTop: "20rpx"
				},
				row: [],
				showLoading: false,
				contentUnlock: '',
				showUnlock: false,
				password: '',
				showResetPwd: false,
				scrollTop: 0,
				innerScrollTop: 0,
				fileList: [],
				listStyles: {
					"borderStyle": {
						"width": "0", // 边框宽度
					},
					"border": false, // 是否显示边框
					"dividline": false
				},
				dataList: [],
				current: 0,
				data: new Date().toISOString().slice(0, 10),
				disabledDates: ["2025-10-11", "2025-10-12", "2025-10-13"],
				start: new Date().setDate(new Date().getDate() + 1),
				end: '',
				isStopBodyScroll: false, // 是否阻止页面滑动
				fileList1: [],
				showPushDialog:false,
				pushList:[]
			}
		},
		created() {
			this.getList()
			console.log('new Date().toISOString().slice(0, 10)', new Date().toISOString().slice(0, 10))
		},
		// onShow() {
		// 	this.getList()
		// },
		onReady() {
			uni.hideTabBar() //隐藏导航栏方法
		},
		onPullDownRefresh() {
			console.log('refresh');
			this.getList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			lookDetail(item){
				console.log('查看',item)
				uni.navigateTo({
					url: `../../package_pushRecord/pushRecord/pushRecord?recordId=${item}`
				})
			},
			repeat(item){
				// recordUse(item).then(res=>{
				// 	console.log('复用',res)
				// })
			},
			listRecord(){
				listRecord().then(res=>{
					console.log('发送记录',res)
					this.pushList=res.rows
				})
			},
			handlePush(){
				this.showPushDialog=true
				this.listRecord()
				this.isStopBodyScroll = true
			},
			confirmPush(){
				this.showPushDialog=false
				this.isStopBodyScroll = false
			},
			
			imgpre(item) {
				let img = 'http://192.168.1.143:8089/common/file/' + item + '/previewOriginal'
				// let img="https://bzh.jyssp.cn:8686/system/picture/CheckPicture?fileKey=2rL4A2MepA5gt2cL03Yv"
				console.log('img', img)
				let a = [];
				a[0] = img;
				uni.previewImage({
					urls: a,
				})
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1);
			},
			// 新增图片
			async afterRead(event) {
				console.log('event', event)
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: "http://192.168.1.143:8089/common/file/upload", // 仅为示例，非真实的接口地址
						filePath: event.file.url,
						name: "file",
						header: {
							'Authorization': 'Bearer ' + getToken(),
						},
						formData: {
							file: event.file,
							bizType: '0'
						},
						success: (res) => {
							console.log('res', JSON.parse(res.data).data.id)
							this.model1.taskFile = JSON.parse(res.data).data.id
							this.fileList1.push({
								url: 'http://192.168.1.143:8089/common/file/' + this.model1
									.taskFile + '/previewOriginal'
							})
						},
					});
				});
			},
			uploadSuccess(e) {
				console.log('上传成功', e)
			},
			uploadFail(e) {
				console.log('上传失败：', e)
			},
			selectUpload(e) {
				console.log('上传：', e)

				uni.uploadFile({
					url: 'url', //仅为示例，非真实的接口地址
					filePath: e.tempFilePaths[0],
					name: 'file',
					// formData: {
					// 	'file': ''
					// },
					success: (uploadFileRes) => {
						console.log(uploadFileRes.data);
					},
					fail: (err) => {
						console.log(err);
					}
				})
			},
			/** 导入按钮操作 */
			handleImport() {},
			onscroll(e) {
				// console.log('onscroll:', e);
				this.innerScrollTop = e
			},
			/** 解锁按钮操作 */
			handleUnlock() {
				// const username = this.selectName
				this.contentUnlock = '是否确认解锁用户"' + this.row.taskPcNumber + '"数据项?'
				this.showUnlock = true
				// this.$modal.confirm('是否确认解锁用户"' + username + '"数据项?').then(function() {
				//   return unlockLogininfor(username)
				// }).then(() => {
				//   this.$modal.msgSuccess('用户' + username + '解锁成功')
				// }).catch(() => {
				// })
			},
			confirmUnlock() {
				this.showUnlock = false;
				console.log('点击确认')
				unlockLogininfor(this.row.taskPcNumber).then(res => {
					uni.showToast({
						title: '解锁成功',
						duration: 2000
					});
					this.checkboxValue1 = []
					this.getList()
				})
			},
			cancelUnlock() {
				this.showUnlock = false;
			},
			// 重置密码操作
			handleResetPwd() {
				// const username = this.selectName
				this.contentUnlock = '请输入"' + this.row.taskPcName + '"的新密码?'
				this.showResetPwd = true
			},
			confirmResetPwd() {
				this.showResetPwd = false;
				console.log('点击确认')
				resetUserPwd(this.row.userId, this.password).then(res => {
					uni.showToast({
						title: '重置成功',
						duration: 2000
					});
					this.checkboxValue1 = []
					this.getList()
				})
			},
			cancelResetPwd() {
				this.showResetPwd = false;
			},
			showProjectNameCancel() {
				this.showProjectNameDialog = false
				this.projectName = ''
				this.sendType = ''
				this.isStopBodyScroll = false
			},
			showSendDateCancel() {
				this.showSendDateDialog = false
				this.showProjectNameDialog = true
			},
			showDeadlineCancel() {
				this.showDeadlineDialog = false
				this.showSendDateDialog = true
			},
			showConfirmCancel() {
				this.showConfirmDialog = false
				this.showDeadlineDialog = true
			},
			close() {
				this.showConfirmDialog = false
				this.showDeadlineDialog = false
				this.showSendDateDialog = false
				this.showProjectNameDialog = false
				this.projectName = ''
				this.sendType = ''
				this.isStopBodyScroll = false
			},
			changes(e) {
				// console.log('e', e)
				// this.queryParams.pageNum = e
				// this.getList()
				this.scrollTop = this.innerScrollTop
				this.$nextTick(() => {
					this.scrollTop = 0
				})
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 300 // 滚动动画时长，单位ms
				})

			},
			change1(e) {
				console.log('e', e)
				this.queryParams.pageNum = e
				// this.userList=[]
				this.getList()
				this.scrollTop = this.innerScrollTop
				this.$nextTick(() => {
					this.scrollTop = 0
				})
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 300 // 滚动动画时长，单位ms
				})

			},
			getList() {
				let that = this
				that.showLoading = true
				listTaskManagement(that.queryParams).then(res => {
					console.log('res', res)
					// setTimeout(() => {
					that.showLoading = false
					// }, 1000)
					that.TaskManagementList = res.rows.map(item => ({
						...item,
						checked: false // 默认未选中
					}))
					that.total = res.total
					console.log('that.total', that.total)
				})
			},
			// checkboxChange(n) {
			// 	console.log('所有选中的数据', n);
			// 	console.log('checkboxValue1',this.checkboxValue1)
			// 	this.row = n

			// },
			checkboxChange(e) {
				console.log('eee0', e)
				// 获取所有选中的taskId数组
				const checkedTaskIds = e.detail.value;

				// 更新数据源中每个item的checked状态
				this.TaskManagementList.forEach(item => {
					item.checked = checkedTaskIds.includes(item.taskId);
				});
				this.dataList = this.TaskManagementList.map(item => {
					if (checkedTaskIds.includes(item.taskId)) {
						return item
					}
				}).filter(Boolean)
				// 将选中的taskId同步到checkboxValue1（用于批量操作）
				this.checkboxValue1 = checkedTaskIds;
				console.log('所有选中的taskId:', checkedTaskIds);
				console.log('所有选中的this.dataList:', this.dataList);
			},
			groupChange(n) {
				console.log('groupChange', n);
			},
			radioChange(n) {
				console.log('radioChange', n);
			},
			// 发送按钮点击事件
			handleAdd() {
				// 显示项目名称输入框
				sendTask({
					taskIds: this.checkboxValue1,
					type: '0'
				}).then(res => {
					if (res.code == 200) {
						this.showProjectNameDialog = true;
						this.isStopBodyScroll = true
					}
					this.$refs.uToast.show({
						type: "default",
						message: res.msg,
					});
				}).catch(err => this.$refs.uToast.show({
					type: "default",
					message: '发送次数不足，请与客服联系',
				}));

			},

			// 确认项目名称
			confirmProjectName() {
				if (!this.projectName.trim()) {
					uni.showToast({
						title: '请输入项目名称',
						icon: 'none'
					});
					return;
				}
				this.showProjectNameDialog = false;
				this.showSendDateDialog = true;


			},

			// 确认发送日期
			confirmSendDate() {
				if (this.sendType === 'scheduled' && !this.selectedSendDate) {
					uni.showToast({
						title: '请选择发送日期',
						icon: 'none'
					});
					return;
				}
				if (this.sendType === 'immediate') {
					this.end = Date.now()
				} else {
					this.end = this.selectedSendDate
				}
				console.log('this.end', this.end)
				this.showSendDateDialog = false;
				this.showDeadlineDialog = true;
				// 默认选中今天
				this.selectedDeadline = ''
			},

			// 确认截止日期
			confirmDeadline() {
				if (!this.selectedDeadline) {
					uni.showToast({
						title: '请选择截止日期',
						icon: 'none'
					});
					return;
				}
				let data = new Date().toISOString().slice(0, 10)
				// 格式化日期显示
				// const sendDateText = this.sendType === 'immediate' ? data :`${this.formatDateText(this.selectedSendDate)}`;
				//let length = this.checkboxValue1.length ? this.checkboxValue1.length : this.TaskManagementList.length
				// 构建确认消息
				//this.confirmMessage =`本次发送任务${length}条，任务发送日期${sendDateText}，任务截止日期${this.formatDateText(this.selectedDeadline)}`;

				this.showDeadlineDialog = false;
				this.showConfirmDialog = true;
				if (this.checkboxValue1.length > 0) {
					console.log('选择数据', this.row)
				} else {
					this.dataList = this.TaskManagementList
					console.log('未选择数据', this.row)
				}
			},

			// 最终确认发送
			finalConfirmSend() {
				let params = {
					name: this.projectName,
					taskIds: this.checkboxValue1,
					startTime: this.selectedSendDate,
					endTime: this.selectedDeadline,
					type: '1'
				}
				console.log('params', params)
				// 这里实现实际发送逻辑
				uni.showLoading({
					title: '发送中...'
				});
				sendTask({
					name: this.projectName,
					taskIds: this.checkboxValue1,
					startTime: this.selectedSendDate,
					endTime: this.selectedDeadline,
					type: '1'
				}).then(res => {
					if (res.code === 200) {
						this.$modal.closeLoading()
						this.hasSentToday = true;
						this.showConfirmDialog = false;
						this.projectName = '';
						this.selectedSendDate = '';
						this.selectedDeadline = '';
						// uni.showToast({
						// 	title: res.msg,
						// });
						// uni.showLoading({
						// 	title: res.msg
						// });
						// setTimeout(()=>{
						// 	uni.hideLoading();
						// },5000)
						// uni.showModal({
						// 	title: '提示',
						// 	content: res.msg,
						// 	showCancel:false,
						// 	success: function (res) {

						// 	}
						// });
						this.$refs.uToast.show({
							type: "default",
							message: res.msg,
						})
						// 可以在这里调用刷新列表等操作
						this.getList()
						this.isStopBodyScroll = false
					}
				})
			},

			// 辅助方法：格式化日期
			formatDate(date) {
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				return `${year}-${month}-${day}`;
			},

			// 辅助方法：格式化日期显示文本
			formatDateText(dateStr) {
				const date = new Date(dateStr);
				return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
			},
			handleUpdate() {
				this.show = true;
				this.title = '修改子库管理'
				this.model1 = this.dataList[0]
				this.fileList1.push({
					url: 'http://192.168.1.143:8089/common/file/' + this.model1.taskFile + '/previewOriginal'
				})
				this.isStopBodyScroll = true
			},
			handleDelete() {
				this.showDetle = true
			},
			confirm() {
				this.show = false;
				console.log('点击确认')
				updateTaskManagement(this.model1).then(response => {
					uni.showToast({
						title: '修改成功',
						duration: 2000
					});
					this.isStopBodyScroll = false
					this.open = false
					this.fileList1 = []
					this.getList()
				})
			},
			cancel() {
				this.show = false;
				this.isStopBodyScroll = false
				console.log('点击取消')
			},
			confirmDetle() {
				this.showDetle = false;
				console.log('点击确认')
				delTaskManagement(this.row.taskId).then(res => {
					uni.showToast({
						title: '删除成功',
						duration: 2000
					});
					this.getList()
				})
			},
			cancelDetle() {
				this.showDetle = false;
				console.log('点击取消')
			},
			scrolltolower() {
				this.loadmore();
			},
			loadmore() {

			},
		},
	}
</script>

<style scoped>
	.contentButton {
		width: 100%;
		display: flex;
		/* justify-content: space-around; */
		align-items: center;
		padding: 20rpx;
		flex-wrap: wrap;
		/* 添加固定定位，使其相对于视口固定 */
		position: fixed;
		/* 固定在顶部（可根据需求调整 top/left/right/bottom 值） */
		top: 0;
		left: 0;
		right: 0;
		/* 背景色覆盖下方内容（可选，避免透明导致重叠显示） */
		background: #fff;
		/* 可选：添加阴影增强视觉层次 */
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		/* 固定高度（确保列表区域的 margin-top 能准确避开） */
		height: 110px;
		/* 根据实际按钮区域高度调整 */
		/* 确保按钮区域内的按钮居中或按原有布局排列 */
		display: flex;
		align-items: center;
		padding: 0 16px;
	}

	.content {
		min-height: 100vh;
		/* overflow-y: auto; */
		position: relative;
	}

	.fixed-button-area {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 1000;
		background: #fff;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		display: flex;
		flex-wrap: wrap;
	}

	/* 列表容器 */
	.list-container {
		/* margin-top 通过动态样式设置 */
		min-height: calc(100vh - 186px);
		/* 确保最小高度 */
		position: absolute;
		top: 106px;
		padding-bottom: 100px;
		width: 100%;
	}

	.list-inner {
		height: 100%;
	}

	.custom-style {
		width: 200rpx;
		margin: 10px 20rpx;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.send-type-select {
		padding: 10px 0;
	}

	.confirm-message {
		padding: 10px 0;
		line-height: 1.6;
		color: #333;
	}

	.u-radio__icon-wrap {
		margin-right: 0px;
	}

	.scrollLock {
		width: 100%;
		position: fixed;
	}

	.uni-table {
		table-layout: fixed;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.uni-table .uni-table-td {
		table-layout: inherit;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.uni-table .uni-table-th {
		width: 360rpx;
		box-sizing: content-box;
	}

	.name {
		width: 150px;
		height: 25px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	::v-deep .uni-simple-toast_text {
		word-wrap: break-word !important;
	}
</style>